package com.card323.crpg.cmdhandler;

import java.awt.Color;

import com.card323.crpg.Hero;
import com.card323.crpg.exception.CRPGWrongIndexException;

public class BattleCommandHandler extends CommandHandler {

	ItemCommandHandler _item_cmd_handler = new ItemCommandHandler(_hero);
	CommonCommandHandler _common_cmd_handler = new CommonCommandHandler(_hero);

	public BattleCommandHandler(Hero hero) {
		super(hero);
	}

	@Override
	public void handle(String cmd) {
		synchronized (_hero.get_bi()) {
			if (cmd.equals("a")) {
				if (_hero.get_bi().can_attack()) {
					_hero.get_bi().send_attack_cmd();
				} else {
					_hero.send_message("行动点数不足，不能攻击");
				}
			}
			if (cmd.matches("q|w|e|r|t")) {
				try {
					_hero.get_bi().active_skill(cmd);
				} catch (CRPGWrongIndexException e) {
					_hero.send_error_message(e.toString());
				}
			}
		}
		_hero.send_message("请输入战斗指令", Color.BLUE);

	}
}
